﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartSpace.Web
{
    public class SubView : System.Web.UI.UserControl
    {

        public event SwitchEventHandler SwitchView;

        protected void SwitchSubView(string caption, string virtualPath)
        {
            if (SwitchView != null)
            {
                SwitchView(this, new SwitchEventArgs(caption, this.AppRelativeTemplateSourceDirectory + virtualPath, string.Empty));
            }
        }

        protected void SwitchSubView(string caption, string virtualPath, string arguments)
        {
            if (SwitchView != null)
            {
                SwitchView(this, new SwitchEventArgs(caption, this.AppRelativeTemplateSourceDirectory + virtualPath, arguments));
            }
        }

        public virtual void OnShown(System.Collections.Specialized.NameValueCollection arguments)
        {
        }
    }

    public class SwitchEventArgs : EventArgs
    {
        public string Caption { get; set; }
        public string VirtualPath { get; private set; }
        public string Arguments { get; private set; }

        public SwitchEventArgs(string caption, string virtualPath, string arguments)
        {
            Caption = caption;
            VirtualPath = virtualPath;
            Arguments = arguments;
        }
    }

    public delegate void SwitchEventHandler(object sender, SwitchEventArgs e);
}
